package com.cnhis.cloudhealth.clinical.osworks.commonsql.dao;

import com.cnhis.cloudhealth.commons.dao.BaseDao;
import com.cnhis.cloudhealth.commons.utils.Page;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class OperationHocusDao extends BaseDao {

	public Page get16762(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		return this.queryForPage("OsHocus.get16762", map, currPage, pageSize);
	}
	
	public int get16762Count(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		return getSqlSession().selectOne("OsHocus.get16762Count", map);
	}

	public Page get16762_view(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		return this.queryForPage("OsHocus.get16762_view", map, currPage, pageSize);
	}

	public int get16762_viewCount(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		return getSqlSession().selectOne("OsHocus.get16762_viewCount", map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusVDG1(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1", map);
	}

	@SuppressWarnings("rawtypes")
	public List get16775(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.get16775", map);
	}

	@SuppressWarnings("rawtypes")
	public List get880(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.get880", map);
	}

	public Page get882(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		// TODO Auto-generated method stub
		return this.queryForPage("OsHocus.get882", map, currPage, pageSize);
	}
	
	public int get882Count(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		return getSqlSession().selectOne("OsHocus.get882Count", map);
	}

	@SuppressWarnings("rawtypes")
	public List getVat1(String vat01) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getVat1", vat01);
	}

	public int updateVat1(Map vat1Map) throws Exception {
		// TODO Auto-generated method stub
		return getSqlSession().update("OsHocus.updateVat1", vat1Map);
	}

	public void deleteVao1(String vat01) {
		// TODO Auto-generated method stub
		getSqlSession().delete("OsHocus.deleteVao1", vat01);
	}

	public String selectMaxVao1() {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("OsHocus.selectMaxVao1");
	}

	public void insertVao1(Map vao1map) {
		// TODO Auto-generated method stub
		getSqlSession().insert("OsHocus.insertVao1", vao1map);
	}
	
	public void deleteVao2(String vat01) {
		// TODO Auto-generated method stub
		getSqlSession().delete("OsHocus.deleteVao2", vat01);
	}

	public String selectMaxVao2() {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("OsHocus.selectMaxVao2");
	}

	public void insertVao2(Map vao1map) {
		// TODO Auto-generated method stub
		getSqlSession().insert("OsHocus.insertVao2", vao1map);
	}

	public void updateVav1(Map vav1map) {
		// TODO Auto-generated method stub
		getSqlSession().update("OsHocus.updateVav1", vav1map);
	}

	public String selectMaxVav1() {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("OsHocus.selectMaxVav1");
	}

	public void insertVav1(Map vav1map) {
		// TODO Auto-generated method stub
		getSqlSession().insert("OsHocus.insertVav1", vav1map);
	}

	@SuppressWarnings("rawtypes")
	public List getVat1Vax1(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getVat1Vax1", map);
	}

	@SuppressWarnings("rawtypes")
	public List selectCAM1(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.selectCAM1", map);
	}

	public void deleteVav1(Map vat1Map) {
		// TODO Auto-generated method stub
		getSqlSession().delete("OsHocus.deleteVav1", vat1Map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusOneVDG1(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusOneVDG1", map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusSomeVDG1(Map<String, Object> map) {
		return getSqlSession().selectList("OsHocus.getHocusSomeVDG1", map);
	}
	
	public void insertTmpVDG101(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG101", map);
	}
	
	public void insertTmpVDG102(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG102", map);
	}
	
	public void insertTmpVDG103(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG103", map);
	}
	
	public void insertTmpVDG105(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG105", map);
	}
	
	public void insertTmpVDG106(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG106", map);
	}
	
	public void insertTmpVDG107(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG107", map);
	}
	
	public void insertTmpVDG108(Map<String, Object> map) {
		getSqlSession().insert("OsHocus.insertTmpVDG108", map);
	}

	public Long getMaxVdg01() {
		return getSqlSession().selectOne("OsHocus.getMaxVdg01");
	}

	public void updateTmpVDG101(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG101", map);
	}
	
	public void updateTmpVDG102(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG102", map);
	}
	
	public void updateTmpVDG103(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG103", map);
	}
	public void updateTmpVDG105(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG105", map);
	}
	public void updateTmpVDG106(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG106", map);
	}
	public void updateTmpVDG107(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updateTmpVDG107", map);
	}
	public void updateTmpVDG108(Map<String, Object> map) {
		List list = (List) map.get("list");
		for(int i = 0 ; i < list.size() ; i ++){
			Map vdgmap = (Map) list.get(i);
			List vdgList =  getSqlSession().selectList("OsHocus.getVDG1LIST",vdgmap);
			vdgmap.put("list", vdgList);
			if(vdgList.size() > 0){
				getSqlSession().update("OsHocus.updateTmpVDG108", vdgmap);
			}else{
				Long vdg01 = getSqlSession().selectOne("OsHocus.getMaxVdg01");
				vdgmap.put("vdg01", vdg01);
				getSqlSession().insert("OsHocus.insertTmpVDG1LIST", vdgmap);
			}
		}
	}

	@SuppressWarnings("rawtypes")
	public List hoBij02() {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.hoBij02");
	}

	public Page hocudrugBby01(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		return this.queryForPage("OsHocus.hocudrugBby01", map, currPage, pageSize);
	}
	
	public int hocudrugBby01Count(Map<String, Object> map, Integer currPage, Integer pageSize) throws Exception {
		return getSqlSession().selectOne("OsHocus.hocudrugBby01Count", map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusVDG1VDG08(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1VDG08",map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusVDG1VDG10(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1VDG10",map);
	}

	public void delVdg08(Map<String, Object> map) {
		getSqlSession().delete("OsHocus.delVdg08",map);
	}

	public void delVdg01(Map<String, Object> map) {
		getSqlSession().delete("OsHocus.delVdg01",map);
	}

	@SuppressWarnings("rawtypes")
	public List getVAT14_15(Map<String, Object> map) {
		return getSqlSession().selectList("OsHocus.getVAT14_15",map);
	}

	public void updatevat14(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updatevat14", map);
	}

	public void updatevat14null(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updatevat14null", map);
	}

	public void updatevat15(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updatevat15", map);
	}

	public void updatevat15null(Map<String, Object> map) {
		getSqlSession().update("OsHocus.updatevat15null", map);
	}

	@SuppressWarnings("rawtypes")
	public List getHocusVDG1hxVdg08(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1hxVdg08",map);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public List getVdg08Desc(List newList) {
		// TODO Auto-generated method stub
		if(newList.size() > 0){
			Map map=new HashMap<>();
			map.put("list", newList);
			return getSqlSession().selectList("OsHocus.getVdg08Desc",map);
		}else{
			return new ArrayList<>();
		}
	}

	@SuppressWarnings("rawtypes")
	public List getHocusVDG1VDG10VDG11(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1VDG10VDG11",map);
	}

	public List getHocusVDG1VDG09(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.getHocusVDG1VDG09",map);
	}

	public List getVdg09Desc(List<Map<String, Object>> vdgList) {
		if(vdgList.size() > 0){
			Map map=new HashMap<>();
			map.put("list", vdgList);
			return getSqlSession().selectList("OsHocus.getVdg09Desc",map);
		}else{
			return new ArrayList<>();
		}
	}

	public void delVdg09(Map<String, Object> map) {
		getSqlSession().delete("OsHocus.delVdg09",map);
	}

	public void deletetmpList() {
		getSqlSession().delete("OsHocus.deletetmpList");
	}

	@SuppressWarnings("rawtypes")
	public List get16804() {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.get16804");
	}
	
	@SuppressWarnings("rawtypes")
	public List get16805() {
		// TODO Auto-generated method stub
		return getSqlSession().selectList("OsHocus.get16805");
	}

	public Double getVAJ38(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("OsHocus.getVAJ38",map);
	}
	
	public Integer selectMaxvdg08Byvdg03(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("OsHocus.selectMaxvdg08Byvdg03",map);
	}
	
	public void insertTmpVBYyes(List list) throws Exception{
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			getSqlSession().insert("OsHocus.insertTmpVBYyes",param);
		}
		
	}
	
	public void insertTmpVBYno(List list) throws Exception{
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			getSqlSession().insert("OsHocus.insertTmpVBYno",param);
		}
		
	}
	
	@SuppressWarnings({ "rawtypes" })
	public List checkTmpVBYVAJ01(List list) throws Exception{
		List lists=new ArrayList<>();
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			lists=getSqlSession().selectList("OsHocus.checkTmpVBYVAJ01",param);
		}
		return lists;
	}
	
	@SuppressWarnings("rawtypes")
	public List checkTmpVAJ01(List list) {
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			return getSqlSession().selectList("OsHocus.checkTmpVAJ01", param);
		}
		return new ArrayList<>();
	}

	@SuppressWarnings("rawtypes")
	public void insertVBY1(List list, Integer BCE01, Integer BCK01D, String BCE03, String VAF22 ) {
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			param.put("BCE01", BCE01);
			param.put("BCK01D", BCK01D);
			param.put("BCE03", BCE03);
			param.put("VAF22", "'"+VAF22+"'");
			getSqlSession().insert("OsHocus.insertVBY1",param);
		}
	}
	
	@SuppressWarnings("rawtypes")
	public void updateVBY1(List list, Integer BCE01, Integer BCK01D, String BCE03, String VAF22) throws Exception{
		if(list.size()>0){
			Map<String,Object> param = new HashMap<String,Object>();
			param.put("list", list);
			param.put("BCE01", BCE01);
			param.put("BCK01D", BCK01D);
			param.put("BCE03", BCE03);
			param.put("VAF22", VAF22);
			getSqlSession().update("OsHocus.updateVBY1",param);
		}
	}

	public void drug_horate_transfer_data(Map<String, Object> param) {
		getSqlSession().insert("OsHocus.drug_horate_transfer_data",param);
	}
	
}
